package com.luo.service;

import com.luo.spring.*;

@Component("user")
@Scope("prototype")
public class UserService implements BeanNameAware, InitializingBean,UserServiceInterface {
    @Autowired
    private OrderService orderService;

    private String name;

    private User user;
    public OrderService getOrderService() {
        return orderService;
    }

    @Override
    public void setBeanName(String beanName) {
        System.out.println("调用了"+ beanName +"的aware接口");
        name=beanName;
    }



    @Override
    public void afterPropertiesSet() {
        System.out.println("程序员正在干涉spring的bean初始化");
        System.out.println("执行sql语句中为user赋值");
        System.out.println("select name,age from user where id=1");
        user=new User();
        user.setName("王五");
        user.setAge(18);
    }
    public String getName() {
        return name;
    }

    public User getUser() {
        return user;
    }
}
